package o;

import android.app.Activity;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.AsyncTask;
import android.text.TextUtils;
import androidx.annotation.Nullable;
import com.huawei.appgallery.downloadengine.api.SessionDownloadTask;
import com.huawei.appgallery.foundation.service.common.protocol.AppDetailActivityProtocol;
import com.huawei.appgallery.foundation.service.common.protocol.AppDetailActivityProtocol.Request;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.appmarket.service.appmgr.view.activity.AppManagerProtocol;
import com.huawei.appmarket.service.externalapi.view.ThirdApiActivity;
import com.huawei.hms.support.hianalytics.HiAnalyticsConstant.KeyAndValue;
import huawei.widget.HwButton;
import o.col.e;
import o.dyh.d;
import o.ewm.n;

public class dtn implements czv {

    static class b extends AsyncTask {
        private final String ˋ;

        public b(String str) {
            this.ˋ = str;
        }

        protected Object doInBackground(Object[] objArr) {
            Intent intent = new Intent(ContentManager.getInstant().getContext(), ThirdApiActivity.class);
            if (TextUtils.isEmpty(this.ˋ)) {
                intent.setAction(d.ˎ);
            } else {
                intent.setAction(d.ˊ);
                intent.putExtra("KEY_APP_PKG", this.ˋ);
            }
            intent.setFlags(268435456);
            ContentManager.getInstant().getContext().startActivity(intent);
            return null;
        }
    }

    public PendingIntent ˎ() {
        Context ˋ = ContentManager.getInstant().getContext();
        cjo appManagerProtocol = new AppManagerProtocol();
        appManagerProtocol.ˊ().ˊ(true);
        appManagerProtocol.ˊ().ˋ(1);
        appManagerProtocol.ˊ().ˋ(ˋ.getString(n.ˋʻ));
        appManagerProtocol.ˊ().ˊ(KeyAndValue.NUMBER_01);
        Intent ॱ = new cjm("updatemgr.activity", appManagerProtocol).ॱ(ˋ);
        ॱ.setFlags(536870912);
        return PendingIntent.getActivity(ˋ, 2016062801, ॱ, 268435456);
    }

    public void ॱ(Context context) {
        cjm ˏ = new AppManagerProtocol().ˏ();
        if (!(context instanceof Activity)) {
            ˏ.ॱ().addFlags(268435456);
        }
        cjk.ˎ().ˋ(context, ˏ);
    }

    public void ˎ(String str, String str2, String str3) {
        dsl.ˊ(str, str2, str3, 0, coc.NORMAL);
    }

    public void ॱ(@Nullable String str) {
        dsi.ˏ(new b(str));
    }

    public SessionDownloadTask ˏ(String str) {
        return dvt.ˏ().ˎ(str);
    }

    public void ˎ(String str) {
        SessionDownloadTask ˋ = dvt.ˏ().ˋ(str);
        if (ˋ != null) {
            dvt.ˏ().ॱ(ˋ.ʾ());
        }
    }

    public float ˏ() {
        return dkk.ˊ();
    }

    public Bitmap ˋ(Context context) {
        return dkk.ॱ(context);
    }

    public void ˎ(CardBean cardBean) {
        int ˊ = etn.ˊ(1);
        fhz ˋ = fho.ˏ().ˋ("PackageManager");
        if (ˋ != null) {
            cnw o_cnw = (cnw) ˋ.ॱ(cnw.class);
            if (o_cnw != null) {
                o_cnw.ˋ(ContentManager.getInstant().getContext(), new e().ॱ(cardBean.ॱـ()).ˋ(coc.IMPORTANCE).ˏ(ˊ).ॱ(new coe(cardBean.v_())).ˏ(dwq.ˊ).ॱ());
                return;
            }
            Logger.e("UpdateReverseDependencyImpl", "can not found IPackageInstaller Api");
            return;
        }
        Logger.e("UpdateReverseDependencyImpl", "can not found PackageManager module");
    }

    public void ˋ(Context context, CardBean cardBean) {
        if (cardBean == null || context == null) {
            Logger.e("UpdateReverseDependencyImpl", "startDetailActivity, cardBean = " + cardBean + ", context = " + context);
            return;
        }
        cjo appDetailActivityProtocol = new AppDetailActivityProtocol();
        appDetailActivityProtocol.ˏ(new Request(cardBean.ॱॱ(), null));
        cjk.ˎ().ˋ(context, new cjm("appdetail.activity", appDetailActivityProtocol));
    }

    public void ˊ(Activity activity, HwButton hwButton) {
        new due().ˊ(activity, hwButton);
    }
}
